from django import forms
from models import Event
from bootstrap_toolkit.widgets import BootstrapDateInput
from workout.widgets import BootstrapTimeInput
from django.forms.widgets import Textarea

class EventForm(forms.ModelForm):
 
    def __init__(self, *args, **kwargs):
        super(EventForm, self).__init__(*args, **kwargs)

        for key in self.fields:
            if key != 'description' :
                self.fields[key].required = True
            if key == 'time' :
                self.fields[key].input_formats = ['%I:%M %p'];
    class Meta:
        model = Event
        exclude = ("owner", "participants",)
        widgets = {
            'description' : Textarea(attrs={'rows':4}),
            'date' : BootstrapDateInput(format="%m/%d/%Y"),
            'time' : BootstrapTimeInput(),
        }
    
